﻿/*****************************************************************//**
 * @file    FITKOCCGraphObjectModelPreview.h
 * @brief   Graph object for previewing OCC model.
 *
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-08-28
 *********************************************************************/

#ifndef __FITKOCCGRAPHOBJECTMODELPREVIEW_H__
#define __FITKOCCGRAPHOBJECTMODELPREVIEW_H__

#include "FITKOCCGraphObject3D.h"

#include "FITKOCCGraphAdaptorAPI.h"

#include <QColor>

 // Forward declaration
class QVariant;

class TopoDS_Shape;

class FITKOCCAIS_ColoredShape;

namespace Interface
{
    class FITKAbsGeoCommand;
}

namespace Exchange
{
    struct _ShapeIndiceMap;
}

namespace Exchange
{
    /**
     * @brief   Graph object for previewing OCC model.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-08-28
     */
    class FITKOCCGRAPHADAPTORAPI FITKOCCGraphObjectModelPreview : public FITKOCCGraphObject3D
    {
        // Regist
        FITKGraphObjectRegist(FITKOCCGraphObjectModelPreview, FITKOCCGraphObject3D);
        FITKCLASS(Exchange, FITKOCCGraphObjectModelPreview);

    public:
        /**
         * @brief   Constructor.
         * @param   modelData: The model data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        FITKOCCGraphObjectModelPreview(Interface::FITKAbsGeoCommand* modelData);

        /**
         * @brief   Destructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        ~FITKOCCGraphObjectModelPreview();

        /**
         * @brief   Update the graph object.[override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        void update(bool forceUpdate = false) override;

        /**
         * @brief   Update the interactive objects in graph object.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        void updateInteractiveObjs() override;

        /**
         * @brief   Set the color to all vertice, edges and faces.[override]
         * @param   color: The color
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        void setColor(QColor color) override;

        /**
         * @brief   Enable or disable transparency.[override]
         * @param   isOn: Enable or not
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        void setEnableTransparency(bool isOn) override;

        /**
         * @brief   Set the shape of point mark.[virtual]
         * @param   type: The type of the point mark
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        void setPointMark(FITKOCCCommons::PointMarkShape type) override;

        /**
         * @brief   Set the point size of vertice' marks.[override]
         * @param   factor: The size factor( default 1.0 )
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        void setPointSizeScale(double factor) override;

        /**
         * @brief   Set the line width of the edges( wire ).[override]
         * @param   size
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        void setLineWidth(double size) override;

        /**
         * @brief   Hide or show the graph object's interactive objects.[override]
         * @param   visibility: The visibility.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        void setVisible(bool visibility) override;

    protected:
        /**
         * @brief   Constructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        FITKOCCGraphObjectModelPreview() = default;

    private:
        /**
         * @brief   Initialize.
         * @param   Is OK
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        bool initShapeData();

        /**
         * @brief   Generate the AIS_Shape with the TopoDS_Shape data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        void generateShape();

    private:
        /**
         * @brief   The shape data of the model.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        TopoDS_Shape* m_tpShape{ nullptr };

        /**
         * @brief   The interactive object for colored shape data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        FITKOCCAIS_ColoredShape* m_fAisShape{ nullptr };

        /**
         * @brief   The hash code of the shape.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-08-28
         */
        int m_hashCode = -1;

    };
}   // namespace Exchange

#endif // __FITKOCCGRAPHOBJECTMODELPREVIEW_H__
